package leetcode.code1915;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {
	

	public long wonderfulSubstrings(String word) {
		char[] words = word.toCharArray();
		int range = 1 << 10;
		int[] hash = new int[range];
		hash[0] = 1;
		long ans = 0;
		for (int i = 0, cur = 0; i < words.length; i++) {
			cur ^= (1 << (words[i] - 'a'));
			ans += hash[cur];
			for (int j = 0; j < 10; j++) {
				ans += hash[(cur ^ (1 << j))];
			}
			hash[cur]++;
		}
		return ans;
	}


	@Override
	public void debug4() {
		H.compare(4, this.wonderfulSubstrings("aba"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}

